package com.chb.friend2;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * 按照fof数量进行排序
 */
public class Fof2Sort extends WritableComparator{
	public  Fof2Sort() {
		super(User.class, true);
	}
	@Override
	public int compare(WritableComparable a, WritableComparable b) {
		User u1 = (User)a;
		User u2 = (User)b;
		int r1 = u1.getUserName().compareTo(u2.getUserName());
		if (r1 == 0) {
			//按照降序排序
			return  -Integer.compare(u1.getFofNum(), u2.getFofNum());
		}else {
			return r1;
		}
	}
}
